#include "dialog.h"
#include "ui_dialog.h"
#include <QErrorMessage>
#include <QComboBox>


#include "my_DC_motor.h"
#include "my_servo_motor.h"
#include "mainwindow.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);

    enable_button = new QRadioButton("Input Enable", this);
    QRect pos_enable_button = QRect(510,50,82,17);
    enable_button->setGeometry(pos_enable_button);
    enable_button->setAutoExclusive(0);
    enable_button->setChecked(1);
    connect(enable_button, SIGNAL(toggled(bool)), this, SLOT(change_enabling(bool)));
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_goButton_clicked()
{
    QErrorMessage* err = new QErrorMessage(this);
    //err->showMessage(ui->comboBox_1->currentText().trimmed() + " " + ui->comboBox_2->currentText().trimmed());
    err->showMessage("Update Target Positions via SCARA solver...");
    enable_button->setChecked(0);
}

void Dialog::change_enabling(bool checked)
{
    if(checked == true)
        enable();
    else
        disable();
}

void Dialog::enable()
{
    user_enabled_flag = true;
}

void Dialog::disable()
{
    user_enabled_flag = false;
}
